<?php
	if (isset($_POST['AddRequest'])) {
	$Action = $GLOBALS['CONN']->db_query("INSERT INTO ccenter_requests
			(RefUser, RefOffice, RefDomain, Status, TimeCreated)
			VALUES
			({$_SESSION['UtID']},{$_SESSION['office']},0,0,'{$sysTime}')");
	
	} elseif (isset($_POST['UpdateRequest'])) {
	
	$Action = $GLOBALS['CONN']->db_query("UPDATE ccenter_requests
			SET Observations = '{$_POST['Observations']}',
			Status = 1
			WHERE Ref = {$_POST['Ref']}");
	
	} elseif (isset($_POST['AddArticle'])) {
	
	$Action = $GLOBALS['CONN']->db_query("INSERT INTO ccenter_requestarticles
			(RefArticle,RefRequest,Quantity,se,seTYPE)
			VALUES
			({$_POST['Article']},{$_POST['Ref']},'{$_POST['Quant']}',{$_POST['Use']},{$_POST['UseTYPE']})");
	
	} elseif (isset($_POST['RemRequest'])) {
	
	$Action = $GLOBALS['CONN']->db_query("UPDATE ccenter_requests
			SET Status = 5
			WHERE Ref = {$_POST['RemArticle']}");
	
	}
	if (isset($_POST['UpdateRequest'])) {
	$GLOBALS['CONN']->db_query("UPDATE ccenter_requests
			SET 
			TimeCreated = '{$sysTime}',
			Observations = '{$_POST['Observations']}',
			Status = 1
			WHERE Ref = {$_POST['Ref']}");
	
	}
	if (isset($_POST['AddArticle'])) {
	
	$GLOBALS['CONN']->db_query("INSERT INTO ccenter_requestarticles
			(RefArticle,RefRequest,Quantity,se,seTYPE,ArticleDescription)
			VALUES
			({$_POST['Article']},{$_POST['Ref']},'{$_POST['Quant']}',{$_POST['Use']},{$_POST['UseTYPE']},'{$_POST['ArticleDescription']}')");
	
	}
	if (isset($_POST['DelArticle'])) {
	$GLOBALS['CONN']->db_query("UPDATE ccenter_requestarticles
			SET 
			Status = 5
			WHERE Ref = {$_POST['DelArticle']}");
	
	}
	if (isset($_POST['RemRequest'])) {
	
	$GLOBALS['CONN']->db_query("UPDATE ccenter_requests
			SET Status = 5
			WHERE Ref = {$_POST['RemArticle']}");
	
	}
	if (isset($_POST['ArticleID']) && $_POST['ArticleID'] != '') {
	
	$GLOBALS['CONN']->db_query("UPDATE ccenter_requestarticles
			SET 
			Status = {$_POST['ArticleStatus']},
			Quantity = {$_POST['ArticleQuant']},
			seTYPE = {$_POST['ArticleUseTYPE']},
			se  = {$_POST['ArticleUse']},
			ArticleDescription = '{$_POST['ArticleDescr']}'
			WHERE Ref = {$_POST['ArticleID']}");
	
	} 
	if (isset($Action)) {
		$Msg_OPCONFIRM = "Opera��o Executada.";
		} elseif (isset($_POST['UpdateRequest'])) {
		$Msg_ERROR = "Erro, n�o foi poss�vel conclu�r a opera��o.";
		}
?>